package com.zrentech.order.adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.zrentech.order.R;
import com.zrentech.order.data.busibean.FoodBean;

/**
 * Adapter representing food
 * 
 * @author Johnny
 */
public class FoodAdapter extends ArrayListAdapter<FoodBean> {
	
	public FoodAdapter(Activity context) {
		super(context);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View row=convertView;

		ViewHolder holder;

		if (row==null) {
			LayoutInflater inflater = mContext.getLayoutInflater();
			row=inflater.inflate(R.layout.food_item, null);

			holder = new ViewHolder();
			/*holder.image = (RemoteImageView)row.findViewById(R.id.AlbumRowImageView);
			holder.albumText = (TextView)row.findViewById(R.id.AlbumRowAlbumTextView);
			holder.artistText = (TextView)row.findViewById(R.id.AlbumRowArtistTextView);
			holder.progressBar = (ProgressBar)row.findViewById(R.id.AlbumRowRatingBar);*/

			row.setTag(holder);
		}
		else{
			holder = (ViewHolder) row.getTag();
		}
		
		/*
		holder.image.setDefaultImage(R.drawable.no_cd);
		holder.image.setImageUrl(mList.get(position).getImage(),position, getListView());
		holder.albumText.setText(mList.get(position).getName());
		holder.artistText.setText(mList.get(position).getArtistName());
		holder.progressBar.setMax(10);
		holder.progressBar.setProgress((int) (mList.get(position).getRating()*10));*/

		return row;
	}
	
	/**
	 * Class implementing holder pattern,
	 * performance boost
	 * 
	 * @author Johnny
	 */
	static class ViewHolder {
		ImageView image;
		TextView albumText;
		TextView artistText;
		ProgressBar progressBar;
	}
}
